#filename funciton.py
def sayHello():
	print('hello world')
sayHello()
sayHello()

#函数传参
def printMax(a,b):
	if(a > b):
		print(a,'是最大的')
	elif a < b:
		print(b,'最大的')
	else:
		print(a,'等于',b)
printMax(1,2)
printMax(2,2)
printMax(3,4)

#局部变量
x = 50
def func(x):
	print(x)
	x = 20
	print(x)
func(x)
print(x)

#全局
y = 100
def func():
	global y
	print(y)
	y = 1
	print(y)
func()
print(y)

#非局部变量
def funcOut():
	x = 5
	print(x)
	def funcIn():
		nonlocal x
		x = 2
	funcIn();
	print(x)
funcOut()

# 默认  默认值必须在后面 
def say(message,times = 1):
	print(message * times)
say('hello')
say('hello',6)

#关键参数
def func(a,b=10,c=100):
	print(a,'@',b,'@',c)
func(1)
func(c=1,a=2,b=3)

#varargs 参数
def total(init,*numbers,**keywords):
	count = init
	print(numbers)
	print(keywords)
	for number in numbers:
		count +=number
	for keyword in keywords:
		count +=keywords[keyword]
	return count;
print( total(10,11,12,13,a=10,b=20))

#空返回 None
def empty():
	"""Test 函数返回值。

	测试没有return的时候返回值是什么"""
	pass
print(empty())
print(empty.__doc__)
help(empty)
